<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'models/m_object.php';

/**
 * Модель комментария видео
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */
class M_Comment extends M_Object {
   
   /**
    * Название таблицы
    *
    * @access protected
    * @var string
    */
   var $_table = 'video_comments';
   
   /**
    * Конструктор класса
    *
    * @access public
    * @return M_Genre
    */
   function M_Comment() {
      parent::M_Object();
   } // end M_Comment
   
   /**
    * Метод активации
    *
    * @access public
    * @return boolean
    */
   function activate() {
      $sql = "
         UPDATE
            " . $this->db->dbprefix($this->_table) . "
         SET
            status = 'active'
         WHERE
            id_comment = " . $this->db->escape($this->get_id('id_comment')) . " AND
            status <> 'active'
         LIMIT
            1
      ";
      if (null !== $this->db->query($sql)) {
         return true;
      }
      return false;
   } // end activate
   
   /**
    * Метод приостановки
    *
    * @access public
    * @return boolean
    */
   function pause() {
      $sql = "
         UPDATE
            " . $this->db->dbprefix($this->_table) . "
         SET
            status = 'paused'
         WHERE
            id_comment = " . $this->db->escape($this->get_id('id_comment')) . " AND
            status <> 'paused'
         LIMIT
            1
      ";
      if (null !== $this->db->query($sql)) {
         return true;
      }
      return false;
   } // end pause
   
}
